﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="HMS.PL.Forms.CreateMenuOptions" %>

<% Response.AddHeader("Pragma", "no-cache"); %>
<% Response.AddHeader("Cache-Control", "no-cache"); %>
<% Response.AddHeader("Cache-Control", "no-store"); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link type="text/css" rel="stylesheet" href="../Style/!style1.css" />
    <link type="text/css" rel="stylesheet" href="../Style/common.css" />
    <title>Select Create Menu</title>
    <script type="text/javascript" src="../Scripts/Tree.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-1.6.1.js"></script>
    <script id="tmplListOptions" type="text/x-jquery-tmpl"> 
        <option value=${Value}>${Text}</option>
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            ////debugger;
            //var obj = parent.$('#demo').jstree('get_selected')
            var id = $("#hid_NodeId").val();
            var type_id = $("#hid_NodeTypeId").val();
            var hier_id = $("#hid_HierarchyId").val();
            var table_name = $("#hid_TableName").val();
            var txtdate = $("#hid_txtdate").val();
            var vers_id = $("#hid_VersionId").val();

            //alert(txtdate);
            get_create_children(id, type_id, table_name, hier_id, vers_id, "drp_NodeType", txtdate);
        });

        function get_create_children(id, type_id, table_name, hier_id, vers_id, comboid, txt_date) {

            //debugger;
            $.ajax({
                async: true,
                type: 'POST',
                url: "Callback.aspx?operation=create_child&id=" + id + "&type_id=" + type_id + "&hier_id=" + hier_id + "&vers_id=" + vers_id + "&table_name=" + table_name + "&txtdate=" + txt_date,
                success: function (str) {

                    var data = eval('(' + str + ')');
                    $("#" + comboid).empty();
                    var strOptions = "";

                    $.each(data, function (i, elm) {
                        // //debugger;
                        strOptions = strOptions + "<option value=" + elm.Value + ">" + elm.Text + "</option>";
                    });

                    $("#" + comboid).append(strOptions);
                    //return data;
                }
            });
        }

        function Submit() {

            ////debugger;
            if (!$.trim($("#txt_NodeName").val())) {
                alert("Please enter the node name !");
                return false;
            }
            if (!$("#drp_NodeType option:selected").length) {
                alert("Please select at least 1 option !");
                return false;
            }

            // //debugger;
            window.returnValue = "{ NodeName: '" + $("#txt_NodeName").val() + "', NodeType: '" + $("#drp_NodeType").val() + "', rel: '" + $("#drp_NodeType :selected").text() + "'}";
            window.close();

        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
        <table>
            <tr>
                <td style="padding-top: 20px; text-align: left;">
                    Enter the Name of the Node
                </td>
            </tr>
            <tr>
                <td>
                    <input type="text" id="txt_NodeName" class="popupInput" />
                </td>
            </tr>
            <tr>
                <td style="text-align: left;">
                    Select the Type of the node
                </td>
            </tr>
            <tr>
                <td>
                    <select size="5" id="drp_NodeType" class="popupSelect">
                    </select>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <input type="button" value="Submit" onclick="javascript:Submit();" class="popupButton" />
                    <input type="button" value="Cancel" onclick="javascript:self.close();" class="popupButton" />
                    <asp:HiddenField ID="hid_NodeId" runat="server" />
                    <asp:HiddenField ID="hid_NodeTypeId" runat="server" />
                    <asp:HiddenField ID="hid_TableName" runat="server" />
                    <asp:HiddenField ID="hid_HierarchyId" runat="server" />
                    <asp:HiddenField ID="hid_VersionId" runat="server" />
                    <asp:HiddenField ID="hid_txtdate" runat="server" />                   
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
